<template>
	<!-- 首页-公告列表 -->
	<view>
		<!-- <u-navbar back-icon-color="#000000" title="公告" title-color="#3F3F3F" :title-bold="true" :background="background"></u-navbar> -->
			<u-navbar back-text="公告" :back-text-style="textStyle" back-icon-color="#000000" style="font-weight: bold;font-family: PingFang SC;"></u-navbar>
			<!-- 公告列表 -->
			<view v-if="isShow">
				<view @tap="jumpToNoticeDetails(item.noticeId)"
				v-for="(item,index) in noticeList" :key="index" 
				:data-id="item.noticeId" 
				style="margin:44rpx 0;">
					<view class="typeface2">{{item.publishTime}}</view>
					<view class="tables">
						<image :src="item.imageUrl" style="width: 100%; height: 272rpx;" mode="aspectFill"></image>
						<view class="typeface1" style="padding: 22rpx 0rpx 24rpx 22rpx;">
							 {{item.title}}
						</view>
					</view>
				</view>
			</view>
			<view v-if="!isShow" style="margin-top: 100rpx;text-align: center;">
				<image src="../../../static/img/1-35.png" style="width: 450rpx;height: 450rpx;"></image>
				<view class="typeface3">暂无数据</view>
			</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background:{
					backgroundColor: '#fca800',
				},
				noticeList:[],
				isShow:true,
			}
		},
		onLoad() {
			this.getNotice()
		},
		methods: {
			getNotice(){
				let _this =this
				let opts = {
					way: true, //true JSON请求；false 表单请求
					method: 'post',
					url: 'notice/getList'
				};
				_this.http.httpTokenRequest(opts).then(res => {
					//打印请求返回的数据
					if (res.code == 200) {
						if(res.data.records.length>0){
							_this.isShow=true;
							_this.noticeList = res.data.records;
						}else{
							_this.isShow=false;
						}
					} else {
						_this.$refs.uToast.show({
							title: res.message,
							type: 'error',
						})
					}
				});
			},
			//跳转公告详情
			jumpToNoticeDetails(e){
				uni.navigateTo({
					url:'./noticeDetails/noticeDetails?id='+ e,
				});
			},
		}
	}
</script>

<style>

.tables{
	margin-left: 60rpx;
	width: 634rpx;
	background: #FFFFFF;
	box-shadow: 0rpx 6rpx 40rpx rgba(0, 0, 0, 0.16);
	opacity: 1;
}
.typeface1{
	font-size: 30rpx;
	font-family: PingFang SC;
	font-weight: bold;
	line-height: 42rpx;
	color: #7A7A7A;
	opacity: 1;
	
}
.typeface2{
	text-align: center;
	margin-bottom: 26rpx;
	font-size: 30rpx;
	font-family: PingFang SC;
	font-weight: 400;
	line-height: 42rpx;
	color: #3F3F3F;
	opacity: 1;
	opacity: 1;
}
.typeface3{
	margin-top: 10rpx;
	font-size: 30rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #666666;
	opacity: 1;
}
</style>
